import java.text.DecimalFormat;

class Person11{
	private String name;
	private int age;
	private boolean gender;
	public Person11(String name, int age,boolean gender) {
		this.name = name;
		this.gender = gender;
		this.age = age;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Person11 other = (Person11) obj;
		if (age != other.age)
			return false;
		if (gender != other.gender)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	
}
class Company{
	private String company;
	public Company(String company) {
		this.company = company;
	}
}
class Employee extends Person11{
    private Company company;
    private double salary;
	public Employee(String name, int age, boolean gender, double salary, Company company) {
		super(name, age, gender);
		this.company = company;
		this.salary = salary;
	}
	
	@Override
	public String toString() {
		return "Employee [company=" + company + ", salary=" + salary + ", toString()=" + super.toString() + "]";
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Employee other = (Employee) obj;
		DecimalFormat df=new DecimalFormat("#.##");
		if(!super.equals(other)) return false;
		if (company == null) {
			if (other.company != null)
				return false;
		} else if (!company.equals(other.company)){
			return false;
		}
		if (!df.format(salary).equals(df.format(other.salary))){
			return false;
		}
		return true;
	}
}
public class Coverequals {

	public static void main(String[] args) {
		Company c1 = new Company("MicroSoft");
		Company c2 = new Company("IBM");
		Person11 e1 = new Employee("Li", 35, true, 60000.124, c1);
		Person11 e2 = new Employee("Li", 35, true, 60000.124, c1);
		Person11 e3 = new Employee("Li", 35, true, 60000.124, c2);
		Person11 e4 = new Employee("Li", 35, true, 60000.123, c2);
		Person11 e5 = new Employee("Li", 35, true, 60000.126, c2);
		Person11 e6 = new Employee("Li", 35, true, 60000.126, null);
		System.out.println(e1.equals(e2));
		System.out.println(e1.equals(e3));
		System.out.println(e3.equals(e4));
		System.out.println(e3.equals(e5));
		System.out.println(e5.equals(e6));

	}
}
